package cn.iocoder.yudao.module.wms.dal.mysql.rdrecord09;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.wms.controller.admin.rdrecord09.vo.Rdrecord09PageReqVO;
import cn.iocoder.yudao.module.wms.dal.dataobject.rdrecord09.Rdrecord09DO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;

/**
 * 其他出库主 Mapper
 *
 * @author 曾劲松
 */
@Mapper
public interface Rdrecord09Mapper extends BaseMapperX<Rdrecord09DO> {

    default PageResult<Rdrecord09DO> selectPage(Rdrecord09PageReqVO reqVO, Collection<String> personIds,
                                                Collection<String> deptIds, Collection<String> warehouseIds,
                                                Collection<String> creator, Collection<String> auditor) {
        return selectPage(reqVO, new LambdaQueryWrapperX<Rdrecord09DO>()
                .likeIfPresent(Rdrecord09DO::getSerialNumber, reqVO.getSerialNumber())
                .inIfPresent(Rdrecord09DO::getPersonId, personIds)
                .inIfPresent(Rdrecord09DO::getDeptId, deptIds)
                .inIfPresent(Rdrecord09DO::getWarehouseId, warehouseIds)
                .betweenIfPresent(Rdrecord09DO::getOrderDate, reqVO.getOrderDate())
                .eqIfPresent(Rdrecord09DO::getRemark, reqVO.getRemark())
                .inIfPresent(Rdrecord09DO::getCreator, creator)
                .betweenIfPresent(Rdrecord09DO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(Rdrecord09DO::getAuditor, auditor)
                .betweenIfPresent(Rdrecord09DO::getAuditTime, reqVO.getAuditTime())
                .eqIfPresent(Rdrecord09DO::getStatus, reqVO.getStatus())
                .orderByDesc(Rdrecord09DO::getId));
    }

    default Rdrecord09DO selectBySerialNumber(String serialNumber) {
        return selectOne(Rdrecord09DO::getSerialNumber, serialNumber);
    }

    default Rdrecord09DO selectByProcessInstanceId(String processInstanceId) {
        return selectOne(Rdrecord09DO::getProcessInstanceId, processInstanceId);
    }

}